
package dao.postgresql;

import dal.Conexion;
import dal.Configuracion;
import dao.TablaDao;
import dto.Tabla;
import java.sql.ResultSet;
import java.util.Vector;

/**
 *
 * @author joseco
 */
public class TablaDaoPostgreSQL extends TablaDao{

    @Override
    public Vector<Tabla> selectTodos() {
        Conexion objConexion = Conexion.getOrCreate();
        
        try {
            Vector<Tabla> objVector = new Vector<Tabla>();
            StringBuffer query = new StringBuffer("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'");
            ResultSet objResultSet = objConexion.ejecutar(query.toString());

            while (objResultSet.next()) {
                String nombreTabla = objResultSet.getString("table_name");
                Tabla objTabla = new Tabla(nombreTabla);
                objVector.addElement(objTabla);
            }
            objConexion.desconectar();
            return objVector;
        } catch (Exception e) {
            e.printStackTrace();
        } finally{
            if(objConexion != null)
                objConexion.desconectar();
        }

        return null;
    }

    
}
